package com.killif;

/**
 * the type of advance
 *
 * <p>
 * .
 *
 * @author 王志强
 * @date 2022-11-08
 */
public enum OrderEnum {
    APPLE(1, "苹果"),
    ORANGE(2, "橘子"),
    BANANA(3, "香蕉");

    private int index;
    private String goods;

    OrderEnum(int index, String goods) {
        this.index = index;
        this.goods = goods;
    }

    public static OrderEnum index(int i) {
        for (OrderEnum anEnum : OrderEnum.values()) {
            if (anEnum.index == i) {
                return anEnum;
            }
        }
        throw new IllegalArgumentException(String.format("No such index: %s OrderEnum Object!", i));
    }

    /**
     * instance member witch named index‘s getter
     * <p>
     * for get field witch named index’s value
     *
     * @return index
     */
    public int getIndex() {
        return index;
    }

    /**
     * instance member witch named goods‘s getter
     * <p>
     * for get field witch named goods’s value
     *
     * @return goods
     */
    public String getGoods() {
        return goods;
    }
}
